Flow.genJava = function(fo){
	var ns = fo.nodes, cn, lv = 1, src = '', imp = [];
	function tabs(s){
		var t = "\t";
		for (var i=0; i<s; i++) {
			t += "\t";
		}
		return t;
	}
	function first(){
		for (var i=1; i<ns.length; i++) {
			var n = ns[i];
			if (!n || !n.d || n.d.o) {
				continue;
			}
			if (!n.check()) {
				alert(Cache.base.flow.node[n.d.t].name
					+ ' ' + (n.d.name || '') + ' 存在问题');
				return;
			}
			if (n.d.t == 'start') {
				return n;
			}
		}
	}
	function next(n){
		var ss = '';
		switch(n.d.t) {
		case 'end':
			ss = tabs(lv) + 'return;' + "\n";
			lv--;
			break;
		case 'process':
		case 'input':
		case 'output':			
			ss = tabs(lv) + '//TODO ' + n.d.memo + "\n\n";
			ss += next(n.n.n);
			break;
		case 'judge':
			src += tabs(lv) + '//TODO ' + n.d.memo + "\n";
			src += tabs(lv) + 'if (true) {' + "\n";
			lv++;
			n = n.n;
			var yes = '', no = '';
			for (var k in n) {
				var z = n[k], t = z.d.tagCode, d = z.n.d;
				if (t == 'yes') {
					yes += next(z.n);
				} else if (t == 'no') {
					no += next(z.n);
				}
			}
			lv--;
			src += yes;
			src += tabs(lv) + '} else {' + "\n";
			src += no;
			src += tabs(lv) + '}' + "\n";
			break;
		case 'switch':
			ss = tabs(lv) + 'switch(' + n.d.code + ') {' + "\n";
			for (var k in n) {
				var z = n[k], t = z.d.tagCode;
				ss += tabs(lv) + 'case ' + t + ':' + "\n";
				lv++;
				ss += tabs(lv) + next(z.n) + "();\n";
				ss += tabs(lv) + 'break;' + "\n";
				lv--;
			}
			break;
		}
		return ss;
	}
	//
	var n = first();
	if (!n) {
		return;
	}
	imp.push('com.boarsoft.flow.bean.SimpleFlowBean');
	src += 'public class ' + fo.d.o.code + ' implements Runnable {' + "\n";
	src += '	@Override' + "\n";
	src += '	public void run() {' + "\n";
	src += next(n.n.n);
	src += '	}' + "\n";
	src += '}';
	return src;
}